home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Tools / Languages / Icon 8.1 / msm-1 / preproc.sit / p_err.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-09-19  |  2.5 KB  |  144 lines  |  [TEXT/MPS ]

  1. /*
  2.  * The functions in this file print error messages.
  3.  */
  4. #include "::preproc:preproc.h"
  5. #include "::preproc:pproto.h"
  6. extern char *progname;
  7.  
  8. /*
  9.  * Prototypes for static functions.
  10.  */
  11. hidden novalue rm_files Params((noargs));
  12.  
  13. static struct id_lst *file_lst = NULL;
  14.  
  15. /*
  16.  * errt1 - error message in one string, location indicated by a token.
  17.  */
  18. novalue errt1(t, s)
  19. struct token *t;
  20. char *s;
  21.    {
  22.    errfl1(t->fname, t->line, s);
  23.    }
  24.  
  25. /*
  26.  * errfl1 - error message in one string, location given by file and line.
  27.  */
  28. novalue errfl1(f, l, s)
  29. char *f;
  30. int l;
  31. char *s;
  32.    {
  33.    fflush(stdout);
  34.    fprintf(stderr, "%s: File %s; Line %d: %s\n", progname, f, l, s);
  35.    rm_files();
  36.    exit(ErrorExit);
  37.    }
  38.  
  39. /*
  40.  * err1 - error message in one string, no location given
  41.  */
  42. novalue err1(s)
  43. char *s;
  44.    {
  45.    fflush(stdout);
  46.    fprintf(stderr, "%s: %s\n", progname, s);
  47.    rm_files();
  48.    exit(ErrorExit);
  49.    }
  50.  
  51. /*
  52.  * errt2 - error message in two strings, location indicated by a token.
  53.  */
  54. novalue errt2(t, s1, s2)
  55. struct token *t;
  56. char *s1;
  57. char *s2;
  58.    {
  59.    errfl2(t->fname, t->line, s1, s2);
  60.    }
  61.  
  62. /*
  63.  * errfl2 - error message in two strings, location given by file and line.
  64.  */
  65. novalue errfl2(f, l, s1, s2)
  66. char *f;
  67. int l;
  68. char *s1;
  69. char *s2;
  70.    {
  71.    fflush(stdout);
  72.    fprintf(stderr, "%s: File %s; Line %d: %s%s\n", progname, f, l, s1, s2);
  73.    rm_files();
  74.    exit(ErrorExit);
  75.    }
  76.  
  77. /*
  78.  * err2 - error message in two strings, no location given
  79.  */
  80. novalue err2(s1, s2)
  81. char *s1;
  82. char *s2;
  83.    {
  84.    fflush(stdout);
  85.    fprintf(stderr, "%s: %s%s\n", progname, s1, s2);
  86.    rm_files();
  87.    exit(ErrorExit);
  88.    }
  89.  
  90. /*
  91.  * errt3 - error message in three strings, location indicated by a token.
  92.  */
  93. novalue errt3(t, s1, s2, s3)
  94. struct token *t;
  95. char *s1;
  96. char *s2;
  97. char *s3;
  98.    {
  99.    errfl3(t->fname, t->line, s1, s2, s3);
  100.    }
  101.  
  102. /*
  103.  * errfl3 - error message in three strings, location given by file and line.
  104.  */
  105. novalue errfl3(f, l, s1, s2, s3)
  106. char *f;
  107. int l;
  108. char *s1;
  109. char *s2;
  110. char *s3;
  111.    {
  112.    fflush(stdout);
  113.    fprintf(stderr, "%s: File %s; Line %d: %s%s%s\n", progname, f, l,
  114.        s1, s2, s3);
  115.    rm_files();
  116.    exit(ErrorExit);
  117.    }
  118.  
  119. /*
  120.  * addrmlst - add a file name to the list of files to be removed if
  121.  *   an error occurs.
  122.  */
  123. novalue addrmlst(fname)
  124. char *fname;
  125.    {
  126.    struct id_lst *id;
  127.  
  128.    id =  new_id_lst(fname);
  129.    id->next = file_lst;
  130.    file_lst = id;
  131.    }
  132.  
  133. /*
  134.  * rm_files - remove files that must be cleaned up in the event of an
  135.  *   error.
  136.  */
  137. static novalue rm_files()
  138.    {
  139.    while (file_lst != NULL) {
  140.       unlink(file_lst->id);
  141.       file_lst = file_lst->next;
  142.       }
  143.    }
  144.